<HTML><HEAD><TITLE>compare_instances(-Relationship, ?Term1, ?Term2)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Comparing and Sorting</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>compare_instances(-Relationship, ?Term1, ?Term2)</H1>
Succeeds if Relationship is an atom describing the instance relationship
between Term1 and Term2.


<DL>
<DT><EM>Relationship</EM></DT>
<DD>Variable or one of the atoms '&lt;', '&gt;', '='
</DD>
<DT><EM>Term1</EM></DT>
<DD>An arbitrary term.
</DD>
<DT><EM>Term2</EM></DT>
<DD>An arbitrary term.
</DD>
</DL>
<H2>Description</H2>
   Succeeds if Relationship is unified with one of the three term
   relationship symbols indicated by '&lt;', '&gt;', '=' where:

<P>
   '&lt;':  Term1 is an instance of Term2.

<P>
   '&gt;':  Term2 is an instance of Term1.

<P>
   '=':  Term1 is variant of Term2.

<P>
   For the definition of instance and variant refer to instance/2 and
   variant/2, respectively.

<P>

<H3>Modes and Determinism</H3><UL>
<LI>compare_instances(-, ?, ?) is det
</UL>
<H3>Fail Conditions</H3>
Fails if none of the terms is an instance of the other
<H2>Examples</H2>
<PRE>
   Success:
   compare_instances(Rel,X,Y), Rel == '='.
   compare_instances(=, [a,X], [a,Y]).
   compare_instances(&lt;, [a,b], [X,Y]).
   compare_instances(&lt;, [X], [X|Y]).
   compare_instances(&gt;, X, f(1,1)).
   compare_instances(&lt;, f(1,1), X).
   Fail:
   compare_instances(Rel, f(X), 1).
   compare_instances(Rel, 1, f(X)).
   compare_instances(&lt;, X, a).



</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/termcomp/instance-2.html">instance / 2</A>, <A HREF="../../kernel/termcomp/variant-2.html">variant / 2</A>
</BODY></HTML>
